<?php get_header(); ?>
<?php
$kw = trim(get_search_query());
if($kw)
{
    global $wpdb;
    $rs = $wpdb->get_results($query);
}
?>
<div id="all-deals">
    <h2><?php echo($kw?'Results match with "'.$kw.'"':''); ?></h2>
    <hr />
    <div class="all-deals-list row-fluid">
    <?php  
        if(count($rs) > 0)
        { 
            foreach ($rs as $p) {
                if($p->post_type == 'post')
                {
                    cpx_get_deal_info($p->ID,1,0,$kw);
                }
                else
                {
                    $store_name = get_post_field('post_title', $p->ID);
                    $description = get_post_field('post_content', $p->ID);
                    $store_logo = get_post_meta($p->ID,'logo_metadata',true);
                    $store_link = get_permalink($p->ID);
                 ?>
                    <div class="row-fluid store-search single-deal">
                        <div class="image-store span2">
                            <a href="<?php echo $store_link;?>" title="see <?php echo $store_name;?> deals">
                                <div class="imgx">
                                    <img src="<?php echo $store_logo; ?>" alt="<?php echo $store_name; ?>" title="<?php echo $store_name.' deals'; ?>" />
                                    <span class="seemore">See deals</span>
                                </div>
                            </a>
                        </div>
                        <div class="span9 description-store">
                            <p><?php echo cpx_highligh_keyword(truncate_str($description,200),$kw);?><a href="<?php echo $store_link;?>" title="read more" class="read_more">Go to <?php echo cpx_highligh_keyword($store_name, $kw);?></a></p>
                        </div>
                    </div>
                    <hr class="search-hr"/>
                <?php }
            }
        }
        else
        {
            echo 'Not found';
        }
    ?>
    </div>
</div>

<?php get_footer(); ?>